Ext.define('carManage.view.menu.MenuTree', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.menutree',
    store:'MenuStore',
     useArrows: true,
    rootVisible: false,
    autoScroll: true,
    enableDD: true, //开启拖拽 
    initComponent: function() {
        this.viewConfig = {
            plugins: {
                ptype: 'treeviewdragdrop'
            },
            listeners: {
                beforedrop: function(node, data, overModel, dropPosition, dropHandlers) {
                    var item = data.records[0].data.id;
                    var menu = overModel.raw.id;
                    var b = true;
                    if (b) {
                        dropHandlers.processDrop();
                    }
                },
                drop: function(node, data, dropRec, dropPosition) {
                    var item = data.records[0].data.id;
                    var menu = dropRec.data.id;
                    
                    Ext.Ajax.request({
                        url: 'ChangeMenuAction.action',
                        params: {
                            item: item,
                            menu: menu
                        },
                        success: function(response) {
                            var text = response.responseText;
                            Ext.Msg.alert("提示", text);
                        }
                    });
                }
            }
        };
        this.callParent(arguments);
    }

});